#ifdef FACTORY_TEST_API
#include "factory_api.h"
#include "config_factory.h"
#include <string.h>

#define DBG_ENABLE
#define DBG_SECTION_NAME "factory_test"
#include "uc_log.h"

void test_factory(void)
{
    char name[32];
    factory_test_state_e state;

    factory_test_result(WIFI_TEST, "wifi", FACTORY_TEST_DEFAULT, "ok");
    factory_test_result(NET_TEST, "net", FACTORY_TEST_DEFAULT, "ok");
    factory_test_result(CAT1_TEST, "cat1", FACTORY_TEST_DEFAULT, "ok");

    factory_test_result(BLUETOOTH_TEST, "bt", FACTORY_TEST_DEFAULT, "ok");
    factory_test_result(UART485_TEST, "485", FACTORY_TEST_DEFAULT, "ok");
    factory_test_result(SD_TEST, "sd", FACTORY_TEST_DEFAULT, "ok");
    factory_test_result(EXTERNAL_FLASH_TEST, "fla", FACTORY_TEST_DEFAULT, "ok");
    factory_test_result(RTC_TEST, "rtc", FACTORY_TEST_DEFAULT, "ok");

    factory_data_save();

    memset(name, 0, 32);
    factory_get_result(WIFI_TEST, name, &state, NULL);
    TRACE_D("wifi test result: %s, %d", name, state);
    memset(name, 0, 32);
    factory_get_result(NET_TEST, name, &state, NULL);
    TRACE_D("net test result: %s, %d", name, state);

    memset(name, 0, 32);
    factory_get_result(CAT1_TEST, name, &state, NULL);
    TRACE_D("net test result: %s, %d", name, state);

    memset(name, 0, 32);
    factory_get_result(BLUETOOTH_TEST, name, &state, NULL);
    TRACE_D("bluetooth test result: %s, %d", name, state);

    memset(name, 0, 32);
    factory_get_result(UART485_TEST, name, &state, NULL);
    TRACE_D("485 test result: %s, %d", name, state);

    memset(name, 0, 32);
    factory_get_result(SD_TEST, name, &state, NULL);
    TRACE_D("sd test result: %s, %d", name, state);

    memset(name, 0, 32);
    factory_get_result(EXTERNAL_FLASH_TEST, name, &state, NULL);
    TRACE_D("external flash test result: %s, %d", name, state);

    memset(name, 0, 32);
    factory_get_result(RTC_TEST, name, &state, NULL);
    TRACE_D("rtc test result: %s, %d", name, state);
}
#endif